<%@ page import="com.onlinevideo.entity.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>信息完善页面</title>
    <link rel="stylesheet" href="../static/css/bootstrap.min.css">
    <script type="text/javascript" src="../static/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="../static/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../static/js/sweetalert.min-2.1.2.js" ></script>
    <style type="text/css">
        .gro{
            margin-bottom: 0px;
        }
        .ope{
            margin-left: 30px;
        }
        body::-webkit-scrollbar{
            display: none;/*隐藏滚动条*/
        }
        .content::-webkit-scrollbar {
            display: none;/*隐藏滚动条*/
        }
    </style>
    <script type="text/javascript">
        $(function (){
            $("#userInfoCompleteBtn").click(function (event){
                event.preventDefault();
                var nickName = $("#nickName").val().trim();
                var phone = $("#phone").val().trim();
                var email = $("#email").val().trim();

                if(nickName.length<=0){
                    swal("警告","请输入昵称" , "error").then(function (isOk){});
                    return;
                }
                if(phone.length<=0){
                    swal("警告","请输入手机号码" , "error").then(function (isOk){});
                    return;
                }
                if(email.length<=0){
                    swal("警告","请输入邮箱" , "error").then(function (isOk){});
                    return;
                }
                var dataInfo = {
                    nickname:nickName,
                    phone:phone,
                    email:email,
                }
                $.ajax({
                    url:"../user.do?action=userInfoComplete",
                    data:dataInfo,
                    dataType:"text",
                    success:function(data){
                        console.log(data)
                        var result = JSON.parse(data)
                        if(result.code == "1"){
                            //4.向用户响应数据（成功，失败）
                            swal("提示",result.message, "success").then(function (isOk){
                                location.href="../gateway?action=mine"
                            });
                        }else{
                            swal("警告",result.message , "error").then(function (isOk){});
                        }
                    },
                    error:function(data){
                        console.log(data);
                    }
                })
            });
        });
    </script>
</head>
<body>
<jsp:include page="header.jsp"/>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="col-md-2 col-sm-2"></div>
                <div class="col-md-8 col-sm-8">
                    <form>
                        <%
                            HttpSession session1 = request.getSession();
                            User user =(User)session1.getAttribute("user");
                            if(user == null ){
                       %>
                            <script type="text/javascript">
                                swal("提示","用户已注销，请重新登录", "error").then(function (isOk){
                                    if(isOk){
                                        location.href = "../view/logo.jsp";
                                    }
                                });
                            </script>
                        <%

                            }
                        %>
                        <div class="form-group">
                            <img src="../uploadFile/images/19.png" style="width: 100px;height: 100px;margin-left: auto;margin-right: auto;margin-top:100px;border-radius: 50%;" class="img-responsive" alt="Responsive image">
                        </div>
                        <div class="form-group">
                            <label for="username">用户名</label>
                            <input type="text" class="form-control" id="username" placeholder="用户名" disabled value="<%= user.getUsername()%>">
                        </div>
                        <div class="form-group">
                            <label for="nickName">昵称</label>
                            <input type="text" class="form-control" id="nickName" placeholder="昵称">
                        </div>
                        <div class="form-group">
                            <label for="phone">手机号</label>
                            <input type="text" class="form-control" id="phone" placeholder="手机号">
                        </div>
                        <div class="form-group">
                            <label for="email">邮箱</label>
                            <input type="email" class="form-control" id="email" placeholder="邮箱" value="<%=user.getUsername()%>">
                        </div>
                        <div class="form-group" style="text-align: center">
                            <button type="button" class="btn btn-primary" id="userInfoCompleteBtn">提交</button>
                            <button type="button" class="btn btn-primary" >取消</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
<jsp:include page="footer.jsp"/>
</body>
</html>
